<?php

	$ssFilter = $this->arrParam['ssFilter'];

	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');

	$lblCat_name 	= $this->cmsLinkSort($this->translate('Category name'),'c.name',$ssFilter,

										$this->imgUrl . '/icon',$action_link);

																			

	$lblOrder 		= $this->cmsLinkSort($this->translate('Order'),'c.order',$ssFilter,

										$this->imgUrl . '/icon',$action_link);	

										

	$lblStatus 		= $this->cmsLinkSort($this->translate('Status'),'c.status',$ssFilter,

										$this->imgUrl . '/icon',$action_link);

										

	$lblCreated 		= $this->cmsLinkSort($this->translate('Created'),'c.created',$ssFilter,

										$this->imgUrl . '/icon',$action_link);									

										

	$lblId 		= $this->cmsLinkSort('ID','id',$ssFilter,

										$this->imgUrl . '/icon',$action_link);	

	

	//CREATE SEARCH AREA

	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort'));

	$linkSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/1');

	$btnSearch = $this->formButton('search-now','Search now',

									array('onclick'=>"OnSubmitForm('" . $linkSearch . "')"));

	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');							

	$btnResetSearch = $this->formButton('clear-keywords','Clear',

									array('onclick'=>"OnSubmitForm('" . $linkResetSearch . "')"));	

	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;	

	

?>

<script type="text/javascript">

	$(document).ready(function(){

		$('strong.show').click(function(e){

			e.preventDefault();

			var id = $(this).parents('tr').attr('class');

			$('tr.child_' + id).toggle();

		});

	});

</script>

<form name="appForm" method="post" action="">

                        <?php echo $this->render('toolbar.php')?>

                        <div class="clr"></div>

                        <?php //echo $this->render('sublink.php')?>



                        <!-- BEGIN: CONTENT -->

                        <div id="element-box">

                            <div class="t">

                                <div class="t">

                                    <div class="t"></div>

                                </div>

                            </div>

                            <div class="m">

                                <!-- BEGIN: ELEMENT BOX -->

								<div id="filters">

									<div>

										<?php echo $strSearch;?>

									</div>

								</div>	

                                <!-- Area 4: In du lieu lay tu database -->

                                <table class="adminlist">

                                    <thead>

                                        <tr>

                                            <th width="43" >

                                            	<input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()">

                                           	</th>

                                            <th><?php echo $lblCat_name ;?></th>

                                            <th width="89"><?php echo $lblStatus ;?></th>

                                            <th width="86"><?php echo $lblOrder;?></th>

                                            <th width="77"><?php echo $this->translate('Created by')?></th>						

                                            <th width="77"><?php echo $lblCreated;?></th>

                                            <th width="90"><?php echo $this->translate('Control')?></th>

                                            <th width="34"><?php echo $lblId;?></th>

                                        </tr>

                                    </thead>

									<?php 

										$i = 0;

										foreach($this->Items as $key => $val){

											$id 		= $val['id'];											

											if($val['level'] == 1){

												$i++;

												$name = '+<strong style="cursor:pointer" class="show" id="'.$id.'"> ' . $val ['name'] . '</strong>';									

												$tmp = $i;

											}else{

												$padding = ($val['level']-1) * 25;

												$padding = 'padding-left:' . $padding . 'px';

												$name = '<div style="'.$padding.'">- ' . $val ['name'] . '</div>';

												$tmp = 'child_' . $i ;

												

											}

											$parent = $val['parents'];											

											$status 	= $val['status'];

											$created 	= $val['created'];

											$created_by 	= $val['created_by'];

											if($status == 1){	

												$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id);											

												$status = $this->cmsAjaxButton('ajax-active-item', 'Active', 'Inactive', $linkStatus, $id);

											}else{

												$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id);

												$status = $this->cmsAjaxButton('ajax-inactive-item', 'Inactive', 'Active', $linkStatus, $id);

											}



											$order			= $this->formText('items['.$id.']',$val['order'],array('class'=>'order'));

											

											$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id);											

											$btnInfo		= $this->cmsIconButton('View Item',$this->imgUrl . '/icon_info.png',$linkInfo);

											

											$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id);

											$btnEdit		= $this->cmsIconButton('Edit Item',$this->imgUrl . '/icon_edit.png',$linkEdit);

											

											$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id);

											$btnDelete =  $this->cmsAjaxButton('ajax-delete-item', 'Delete Item', 'Delete', $linkDelete, $id);

										

											$strIconButton	= $btnInfo . ' ' . $btnEdit . ' ' . $btnDelete;

											

											$cid			= $this->formCheckbox('cid[]',$val['id']);

									?>

                                    <tr class="<?php echo $tmp;?>">						

                                        <td align="center"><?php echo $cid;?></td>

                                        <td align="left"><?php echo $name;?></td>

                                        <td align="center"><?php echo $status;?></td>

                                        <td align="center"><?php echo $order;?></td>

                                        <td align="center"><?php echo $created_by;?></td>

                                        <td align="center"><?php echo $created;?></td>                                        

                                        <td align="center"><?php echo $strIconButton;?></td>

                                        <td align="center"><?php echo $id;?></td>

                                    </tr>

                                    <?php 

										}

                                    ?>

                                </table>

                                <!-- Area 4: In du lieu lay tu database - End -->



                                <!-- END: ELEMENT BOX -->	

                              <div class="clr"></div>

                            </div>

                            <div class="b">

                                <div class="b">

                                    <div class="b"></div>

                                </div>

                            </div>

                        </div>

                        <!-- END: 	CONTENT -->

                    </form>